Serializing with type