bug correction with the gradient.