generator refactoring