Reimplement provided_by(...) function without using equery