Fix invalid query