@SuppressWarnings("rawtypes")
	public boolean connect(String portName) {
		CommPortIdentifier portId = null;
		Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

		// First, Find an instance of serial port as set in PORT_NAMES.
		while (portEnum.hasMoreElements()) {
			CommPortIdentifier currPortId = (CommPortIdentifier) portEnum
					.nextElement();
			if (portName.equals(currPortId.getName())) {
				portId = currPortId;
				break;
			}
		}
		if (portId == null) {
			System.out.println("Could not find COM port.");
			return false;
		}
		if (!portId.isCurrentlyOwned()) {
			try {
				// open serial port, and use class name for the appName.
				serialPort = (SerialPort) portId.open(
						this.getClass().getName(), TIME_OUT);

				// set port parameters
				serialPort.setSerialPortParams(DATA_RATE,
						SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
						SerialPort.PARITY_NONE);
				// serialPort.setEndOfInputChar((byte) 0);
				serialPort.enableReceiveTimeout(1000);
				serialPort.enableReceiveThreshold(0);
				// open the streams
				input = serialPort.getInputStream();
				output = serialPort.getOutputStream();

				// add event listeners
				serialPort.notifyOnDataAvailable(true);
				serialPort.addEventListener(this);
				
				if (!verifySafe()) {
					if (!model.getSearch()) {
						model.setMessage("Not a safe...", JOptionPane.ERROR_MESSAGE);
					}
					return false; //Not a safe...
				}
				
				return true;
			} catch (Exception e) {
				if (e.getClass().toString().equals("class gnu.io.PortInUseException" )) {
					System.out.println("PORT IS IN USE");
				} else {
					System.err.println(e.toString());			
				}
			}
		} else {
			System.out.println("Port is in use!");
		}
		return false;
	}