gradient descent code corrected