fixed query issues