Refactored global.js