Added some dupe prevention logic