Fix check for query