Added error check for invalid email address.