fix detecting of complex path in last segment