Fixed some calculation errors