
The above is the original code.

The above here is what I found sort of "works"
It works in the sense that it prevents items from decreasing (which is what I want it to do), but it also prevents from merging them. So if I was to split 2 away from 4, I retain 4, and gain 2, but then if I try to add that 2 to the 4, it adds to the 4 to make 6, but does not remove the 2 in my inventory (which is what the original code used to do). I have tried to figure it out myself for hours now, but I don't know what I am missing or looking at wrong.