Added histogram calculation