fix query bug