Added code to save indeces to SQL