comment for totalamount function