Refactor global.php