LM least sq opt now working