added track duplicates code, not tested