There is a small error in the code. The variable `count` should be defined on line 11 like:
count = int(record["Count"])
en the appearance on line 15 should be removed.