Rules refactoring