check if query exists