replace totalDue with calculatedTotalDue