updated email function