Refactor global vars