replace local variable totalAmount with function getTotalCharge