fixed email function