separate histogram code