fixed calculation bug