Fixed small bug in the CreateQuery