added code to keep track of subtotal