fix bugs in restore process