! replace the main loop above with this one [ 2dup [ length 1 = ] [ empty? ] bi* and ] [ [ dup [ pos>> ] sort-with ] when-empty pick swap unclip-slice swapd move drop over [ pos>> ] map duplicates pick swap [ [ pos>> ] dip member? ] curry filter [ without ] curry bi@ ] until drop nip first .