bug in residuals fixed