rewrite the logistic regression algorithm.