Reversed the logic for queries as well