Refactor do_state_checks