fix global variable issue