Add total cost. Clean up code