refactored data generator code - used stream instead of for loop