Optimized for loop by removing the array length comparison