implements MOD (tested)