solving matrix