Improve the rename function