Inclusion of secondary extinction in least-squares calculations