Added matrix inversion