changed the mail function