refactor indexing layer