Fix calculation bug