Does this actually need to be pulled out into a top-level variable? Wouldn't it make more sense to pass an `index` into the `buildIndex` function?