refactor globals definition