same as repair-ends.pl