final version before changing linreg to class