Refactored code (iteration)