better highlighting logic