fix calculation bug