Fix bug when query is missing