fixing bug with email sending