Taking out first if statement and putting it on the while statement