simplify main copy loop