logistic algorithm