Fix incorrect indexing the items array in the update() function