the if conditions into a while loop that absorbs cases 2 and 3