Now using "with" in the residuals function to make code much more readable.