Refactored renaming into a function.