Improved the rule generator