fixing the sending of mail twice issue