while loop syntax fix