Improved rewrite RULES