implemented mass mailing and restuctured code