Refactoring shared context