moved the rules engine to its own module