saveInv code