Refactored code due to https://github.com/Gomasy/update_name/commit/d32d73e8fa6560fc8b1a9116a8b5488338828fbc