Changed to do_scan function