Added calculation function