Refactored the code in Mailer part