How to calculate total?