probably neater to just define the query outside the loop statement