matrix inversion works