fix email functionality