xopt is undefined here