refactor context