fixed query errors