Refactor context