added gradient extraction to hessian functions