Added solve algorithm