refactor _find_context