still need to find problem, believe it to be error in gradient, possibly nee jacobian??