readded emailing code