refactored deserialization to the same form as serialization