fixed an error in the email function