refactoring and emailing