Better logic for update_quantity, the culprit of most of this.