Refactor Email function.