add new function for plotting residuals