Refactor Ctx