Solving system of equations