fix bug when storing optim result