function to extract name and email