make process_email a function