added C residual computation