#5 fix double free bug in the backup function