Added error guard to stop renaming in error case.