added better error reports in sgd