Fixed comparison in loop