added leastSquares and factored bestFitLine