adding the gradient and such