Added prevent duplicate functionality