How about just changing the original `m = label_field.max()` (new line 118) to `m = int(label_field.max())`? We shouldn't call an O(n) operation twice!