fix problems in emails script