improving histogram method.
resolved duplicates problem in histogram method