split generator and refactoring