Add a check for the backup file and rearrange functions