public void startscan(){
		worker = new SwingWorker<Void, String>(){
			@Override
			protected Void doInBackground() throws Exception {
				
				view.SetTotalCounter(filesInDirectory.length);
				int index = 0;
				for ( File file : filesInDirectory ) {
					
					if(isCancelled()){
						view.dialog.setVisible(false);
						
						return null;
					}
					
					view.SetNumerator(++index);
					String curimgname = file.getName();
					logger.log(Level.INFO,"Selected file "+curimgname);
					
					try {
						
						sheet = new OmrModel(fh);
						System.gc();
						setProgress(0);
						
						
						sheet.setpaths(curimgname, directory.toString());
						setProgress(5);
						
						sheet.init();
						setProgress(10);
						

						sheet.lookref("first");
						setProgress(20);
						sheet.scale();
						sheet.lookref("second");
						setProgress(25);
						initDocs();
						setProgress(30);
						
						sheet.circle();
						setProgress(40);
						
						initQuestions(sheet.getQuestions(),sheet.getoptions(),sheet.getcols(),sheet.getrows(),sheet.avgr());

						setProgress(50);
						
						String[] results = sheet.getresults();
						setProgress(60);
						
						sheet.drawgrid();
						setProgress(70);
						
						outcsv.println(curimgname+","+Arrays.toString(results));
						setProgress(80);
					
						genrslt(docs,sheet.getstudent(),"OMR", results);
						setProgress(90);
						
						docs.push();
						setProgress(100);
						movefile(file.getPath(),0);
						System.out.println("Relaseing");
						sheet.release();
						publish(curimgname+"#"+sheet.getQrCode()+"#success");
					} catch (UnableToDetectOptions | WrongFileAttributes | UnableToLoadImage | UnableToDetectMarkers | MappingNotCorrect | AssessmentNotExist | CellsWrongDetection | WrongMarkers e1){
						publish(curimgname+"#"+sheet.getQrCode()+"#"+e1.getMessage());
						movefile(file.getPath(),-1);
						
					} catch (CouchDbException e2){
						publish(curimgname+"#"+sheet.getQrCode()+"#Error Code 13");
						movefile(file.getPath(),-1);
					} catch (RuntimeException e2){
						e2.printStackTrace();
						publish(curimgname+"#"+sheet.getQrCode()+"#Error Code 7");
						movefile(file.getPath(),-1);
					} catch (CancelException | QrFailedToDetect e1){
						publish(curimgname+"# #Error Code"+e1.getMessage());
						movefile(file.getPath(),1);
					}
					
				}
				return null;
			}
			@Override
			protected void process(List<String> chunks) {
				for(String line: chunks){
					
					String [] arg = line.split("#");
					display(arg[0],arg[1],arg[2]);
				}
			}
			@Override
			protected void done() {
				view.doCancel();
			}
		};
		worker.addPropertyChangeListener(new PropertyChangeListener() {
			
			@Override
			public void propertyChange(PropertyChangeEvent evt) {
				//System.out.println(evt);
				switch(evt.getPropertyName()){
					case "progress":
						view.SetProgressBarValue((int) evt.getNewValue());
						break;
				}
				
			}
		});
		worker.execute();
	}