I checked again and to me it makes for sense to use range(max_bin) for both loops?