updated

updated function to process emails