Refactor to use a serializer