for loop instead of foreach