almost done the rule engine