Refactoring global variables