modified functions for inverse matrix