Improve highlighting logic