Refactored change of name function