[IMP]improved code for the calculate code and mail send