adding functionality for sgd