Modify update method to handle changing indices