fixed query bug