renamed mod(x, m) to signAwareModulo(x, m)