matrix inversion method fix