fix global variable leak