refactor ctx_block