improved serialization