Fix issue with duplicates in dictionary