fixed dupecheck function