Fixed bug when updating indices