cleaned up mailer code