refactor integer serialization