Made implementation of indexing more flexible