fixed a minor bug and added recursive email send on failure