refactor global context