Fixed with modInverse

Added the change that David suggested