refactoring global vars