new way to compute residuals