shouldn't splice(i,1) take care of the deletion? why are we deleting the element at i and then splicing it out of the array?