Added the calculations to the code