Ok I've done some investigation and I believe the cause could be :
bug 1 - the values in the back end array are actually correct it's just the text hasnt updated because you didnt run the update inventory function again when you swap items, you only run it when you pick items up
bug 2 - you don't update the anim frame value at X to reflect the new item, your focus was on changing the amount at Y which is correct, but the X remains for the previous item. So you update the animation of the item in hand, and the hand amount in the array but not the X value for the type.