Refactored loop block