refactoring escalation mail code