better serializer code structure