@Override
	public void run() {
		
		while(repeat > 0){
		
			ObjectOutputStream out = null;
			ObjectInputStream in = null;
		
			try {
			
				long time1 = System.currentTimeMillis();
			
				Command[] commands = new Command[inputs.length];
			
				for(int i=0; i!=inputs.length; ++i){
					commands[i] = Command.parse(inputs[i]);
				}
				console.append(inputs.length + " commands parsed successfuly\n");
			
				long time2 = System.currentTimeMillis();
				console.append("Parsing time: " + (time2 - time1) + " ms\n");
			
				// prepare socket, input and output streams
				Random r = new Random();
				int index = r.nextInt(nodes.length);
				console.append("Connecting to " + nodes[index] +'\n');
				socket = new Socket(nodes[index].host, nodes[index].port);
				out = new ObjectOutputStream(socket.getOutputStream());
				in = new ObjectInputStream(socket.getInputStream());
				console.append("Connected to " + nodes[index] +'\n');
				
				for(int i=0; i!=commands.length; ++i){
					long time4 = System.currentTimeMillis();
					// send to the node
					out.writeObject(Message.CLIENT);
					out.writeObject(commands[i]);
					console.append("Command " + i + " sent: " + commands[i].input + "\n");
			
					// receive from the node
					if(commands[i].type == Command.SELECT_TABLE){
						resetIndecies();
						Data data = (Data)in.readObject();
						int countSelected = 0;
						while(data.nomoreselected == false){
							if(checkDataForSelect(data)){
								data.display(commands[i].type, console);
								++countSelected;
							}
							data = (Data)in.readObject();
						}
						console.append(countSelected + " row selected\n");
					
					}else{
						Data data = (Data)in.readObject();
						data.display(commands[i].type, console);
					}
					long time5 = System.currentTimeMillis();
					console.append(" + - - - - - - - - - - - - - Elapsed time: " + (time5-time4) + " ms.- - - - - - - - - - - - - - +\n");
				}
			
				out.writeObject(Message.TERMINATE);
			
				long time3 = System.currentTimeMillis();
				console.append("Total execution time: " + (time3 - time2) + " ms.\n");

				// close socket
				socket.close();
				socket = null;
				repeat = 0;
			
			} catch (UnknownHostException e) {
				console.append("1. " + e.getMessage() + "\n");
			} catch (IOException e) {
				console.append("2. " + e.getMessage() + "\n");
			} catch (Exception e) {
				console.append("3. " + e.getMessage() + "\n");
			}finally{
				--repeat;
			}
		}
		
	}