Modified updateIndex function to catch exception