Refactor generation process