stochastic gradient descent with l2 regularization (work in progress) + refactor