manual alternative to modulo