Modified : code logic in e-mail sending