change gobal variable to local variable