fix a global variable issue