Equality rewrite refactor