email refactor