fix bug with gradient descent