Added code to prevent duplicates