Refactor serializer