sgd: some optimization