Fix small query bug