corrected the function to calculate the inverse matrix and added the comments