Abstract the indexing logic to a superclass