refactor unserialize (bis)