abstracted the indexing process