An int isn't interable, see commented out line 453.
Could add an if statement in here and change to range(block_ids), etc etc.