fix global var leak