Fixed calculation bug