Refactored generator