revamped conjugate gradient descent to be more modular