moving index to index file, and all the other necessary adjustments