refactoring in linreg.