refactor Serializer code a bit