added matrix inversion algorithm