Fixed query return bug