Attempted fixes to if statements inside of while loops