move `generateID` to utils
throw an error if pathSegments /= 1