fixed email functionality