Could you check the path here instead of checking the occurrences?