fix a bug in ctx.S