Fixing the conditional in the while loop