refactoring mail