Moved variables under mail, no need for global variable