rewrote email notif code