modify obtaining hessian of optim and add an example