changed linesearch w/ the R loop