kds_s2000w_client_response_free(resp);
        resp = NULL;
        h->current_scan_status->available_images--;
-       sleep(1);
 }
 
 void _download_current_image(handler* h)
        kds_s2000w_client_response_free(resp);
        resp = NULL;
        h->current_scan_status->downloaded_images++;
-       sleep(1);
 }
 
 void _get_current_scan_status(handler* h)
        status_resp_obj = NULL;
        kds_s2000w_client_response_free(resp);
        resp = NULL;
-       sleep(1);
 }
 
 handler* init_handler()
 
        }
 
        for (int i = 0; i < 10; i++) {
-               sleep(1);
                kds_s2000w_handler_get_parameters(h);
                if (h->current_metadata->valid)
                        break;
        }
 
        if (h->current_scan_status->complete_scanned
-               && h->current_scan_status->current_image_number >= h->current_scan_status->downloaded_images)
+               && h->current_scan_status->current_image_number >= h->current_scan_status->downloaded_images
+               && h->current_scan_status->available_images <= 0)
                return SANE_STATUS_NO_DOCS;
 
        return SANE_STATUS_GOOD;