moved state change recognition to new function detect_slice()