fixed a query bug