refactor - improvement of rules engine