refactor contexts