redo im_histgr() as a class