refining email function