Refactorize the generator