Added helper function for hessian and gradient inputs