Parse path index
Refactor pattern detection