refactor extract_case_blocks to look as simple as it is