added a condition if error occured then no need to send an completion email