do_scan: fix errors for multiple scans