working BFGS impementation (-linesearch)