fix division in least squares