fix rounding bug and re-enable optimization
reminder -> remainder