fixed the standard deviation calculation to actually use residuals