modified for sgd data