Refactor migrate_mentioned.py