changed the if statement to until block