Corrected a bug in the renaming function leading to data loss