changing emailing into class, adding some email notifications