add duplication checking code. not sure if it works on mac anymore