updated matrix inverse function-working