Fixed for loop conditions