Rewrite roundUnits function