working LBFGS algorithm