added calculation of total amount