Refactoring global js