updated script with restore