refactor the global variables