moving indexing code to indexer