Adjusting end_block logic