simplifying indexing logic