Clean path detection logic