email service refactor