subtle optimization for iteration