optimized PLeastSquares for automation