// more robust quantity update