Rewritten rule engine