refactored gradient descent out of linear descent