refactor deserialization