fixed errors on calculating totals
organized code on Job