performance fix for autodiff