fixed a bug in hist. implementation