computing sub_total correctly