Weird thing when pick up object

Hello, i just noticed that when the player pick up an object from ground it’s added to inventory as expected, but all the objects of the same type get the id changed. lootid should be different for any object in inventory so this cause some trouble when they are used. The code when pick up object don’t seems wrong to me

                       if (targDB==='potions') {
                            for (var i=0;i<this.dataPotions.length;i++) {
                                if(targName===this.dataPotions[i].name) {
                                    this.inventory.push(this.dataPotions[i]);
                                    this.inventory[this.inventory.length-1].lootID=this.lootUID;
                                    this.lootUID++;
                                }
                            }
                        }