fixing query bug with name selection