rewrite code, and begin email_notify