refactor lib/email