removes the temporary variable total_amount and adds a new function to do this calc