Refactored serializer