fixed ComputeResiduals()