fix the rem implementation (it was modulo)