fixed potential precision issue when calculating results