fix bug in Ctx implementation