wrong value being passed to query