Improve the detection of the path