improved if loops to do-while loops