fix sendquery function