refactoring serialization