significantly tidied the source code for highlight