use histogram -> major speed-up