lots of work, including methods for quantity calculation and checking