Avoid IndexOutOfRangeEx when combining paths