Updated code to do inverse of matrix