Made highlighting code more robust