Optimized for loop