rules refactoring