Replace rounding using int(x+0.5) with roundToInt