fixed major bugs in histogram