added email logic