optimize highlight_window()