changed one of the multiplications in the gradient calculation. hopefully speeds things up