Reimplemented deter_pay query