added error hadnling for email