refactor generation