added error handler and sending email report