Added histogram analysis code