Refactor codes of SaveHandler