Fixed a bug related to sending duplicate emails