working galois gd code, digressing sgd code