add naive duplicate recognition to trace algorithm