move global variable to local