function to remove duplicates from list