Fixed bug in backup function