fix incorrect mod rounding