total calculation function added