removes a query in a loop since the information was already present in the previous query outside the loop.