Extract code for reading indices into separate module