Add serialization function