Move query iteration code back where it was for sake of pull request DIFF.