Added rules and also code to apply those rules