Refactoring for generator and init