rules rewrite and fix