change inverse matrix implementation to a better one.