made .ensure_context optional