fix global var bug