matrix inverse fix