fixed bug so emails are sent