implement modInverse