generator refactorization