Added in residual analysis