fixed bug in sending emails