Refactor code creating assign_labels_to_dst()