refactored code with wallet restore tool