refactor in generator