Refactored Code - Added Generator