Improve the name changing logic