Changed while to do-while