refactoring in mail notification