Refactor so the quanity constraint can be used.