Implementing a fix for dictionary repeating values