fix the stock variation logic