fix some calculations