change send email into one function