Changed dictionary to be a set because it is faster and removed clear being called on list, because apparently that's not a thing in python3