updating the index to dictionary function