stream lining code. refining histogram compare.