added a check to make sure no files are overwriten during the rename