removed debug comments and added email function