private void startConnectLoop() {
		connectLoop = new Thread() {
			@Override
			public void run() {
				final int numSlots = 20;
				int numAttempts = firstConnection ? 0 : 1;
		
				try {
					while(connectLoop != null) {
						Random random = new Random();
						int upperBound = Math.min((int)Math.pow(2, numAttempts), numSlots) - 1;
						long waitTime = random.nextInt(upperBound + 1) * 60 * 1000 / numSlots;
		
						if(numAttempts > 0 || !firstConnection) {
							print("Waiting " + waitTime / 1000 + "s");
						}
		
						Thread.sleep(waitTime);
						try {
							print("---------------------------------------------------");
							XmppConnection connection = new XmppConnection(jid);
							connection.connect();
							print("-------------------- Connected --------------------");
							postMessage(MessageType.CONNECTED, connection);
							break;
						} catch (IOException e) {
							print("---------------- Failed to connect ----------------");
						} catch (XmppException e) {
							postMessage(MessageType.ERROR, e);
							break;
						}
						++numAttempts;
					}
				}
				catch(InterruptedException _) {
				}
			}
		};
		connectLoop.start();
	}