refactor Generator