Bug fix in segment_residuals method