edits on PLeastSquares function