change while loop into do-while