Refactor Restart Scan function