fixed the matrix inversion

matrix inversion was done wrong on previous commit