This `if` block should be placed below `$mentioned_ids = array();` or you will get notice of undefined `$mentioned_ids`.