calc_mod implementation

Signed-off-by: Beni Lev <beniloew@gmail.com>