Performance comes a bit better and fix defect in histgram()