gradient descent loop not working