fixed global variable leak