factor out rewriting for matchers_division