Updated to solve matrix