Refactored code due to https://github.com/Gomasy/update_name/commit/e61cc9daf881d8eb8671849ad0af1aef64365d37 and https://github.com/Gomasy/update_name/commit/e8bca035f65d63f1ddf45e3e722934aec62db22e