Refactor methods in RuleEngine