Updated rules engine