added safe logistic sigmoid