refactored email notification