added error handling for email