bugfix (if query is null, we can't iterate over it)