add histogram build; performance tuning