added code to update image indexes