Added a function to remove duplicates