Generator refactored