Improved path_matching to avoid error:

- Added checking the mathing_list has save length with path_matching.