refactor unserialize