Clean up an ugly do-while loop.