bugfix: send email only if error