create do_binning
simplify
speedup with loops
fix counters