Updated the code to inverse the matrix