changed over detect function in histogram code