Added email on error function