move break condition to loop