Small optimization on for loop