Created apply function for every rule.