duplicates now removed and print statements improved