refine tooltip code