Added calculation code