inventory logic