replaced state-variable with clipdetection