Less comparisons in loop