Refactor the mention detection.