refactor global variable