refactoring generator class