add histogram widget code
simplify markup
generalizing gap function