finished context refactoring