Fixed the calculation bug