Refactor and add extra comments for line highlighting