log reg general function