further code for mega-indexing