While loop didn't stop while out of queries. Clarifying order of operations for evaluations