Emulating modulo