refactor and rename the generator to serializer