public ArrayList<User> joinGameOffMenu(SearchGamesTask jgtl)
			throws InterruptedException, InvalidSubscriptionException,
			IOException {

		this.jgt = jgtl;
		Subscription gameFullSub;
		Subscription gameAdvertisementSub;

		//We want to repeatedly clear the screen, and print out the available
		//games and a prompt asking which username to connect to.
		final Runnable checkForAvailableGames = new Runnable() {
			public void run() {
				// MiscHelper.clearConsole();
				writeCurrentAvailableGames();
			}

			private void writeCurrentAvailableGames() {
				jgt.publishDelegate(availableGames);

			}
		};

		// System.out.println("Searching for available games...");
		availableGames.clear();

		// Subscribe to new game advertisement notifications
		gameAdvertisementSub = elvin.subscribe(NOT_TYPE + " == '" + NEW_GAME
				+ "'");

		// Subscribe to game full notifications.
		gameFullSub = elvin.subscribe(NOT_TYPE + " == '" + GAME_FULL + "'");

		// Whenever a game notification is received, add it to the
		// availableGames list if not in there already
		gameAdvertisementSub.addListener(new NotificationListener() {
			// This is called if we have a response requesting to join our game.
			public void notificationReceived(NotificationEvent event) {

				User tmpUser = new User(event.notification
						.getString("hostUsername"), event.notification
						.getString(GAME_ID),
						byteArrayToPublicKey((byte[]) event.notification
								.get(PUB_KEY)));
				if (findGameHostByID(tmpUser.getID()) == null) {
					availableGames.add(tmpUser);
				}
			}

		});

		// If a game is reported as full, remove it from the available games
		// list.
		gameFullSub.addListener(new NotificationListener() {
			public void notificationReceived(NotificationEvent event) {
				// may need to change this
				User tmpUser = findGameHostByID(event.notification
						.getString(GAME_ID));
				if (tmpUser != null) {
					availableGames.remove(tmpUser);
				}
			}

		});

		notificationHandle = scheduler.scheduleAtFixedRate(
				checkForAvailableGames, 1000, 3000, TimeUnit.MILLISECONDS);

		// Grab the hoster
		try {
			String gameHostString = jgt.waitForInstructionsBuffer.take();
			// System.out.println("I woke up!");
			boolean hostFoundAmongstGames = false;
			for (User usr : availableGames) {
				if (usr.getUsername().equals(gameHostString)) {
					gameHost = usr;
					hostFoundAmongstGames = true;
					break;
				}
				if (!hostFoundAmongstGames) {
					System.err.println("Host not found in available games.");
				}
				// System.out.println("End of for loop");
			}

			// gameHost = availableGames.get(Integer.parseInt(br.readLine()));
		} catch (NumberFormatException e) {
			System.err.println("Your input was not a number!");
			currentGameMembers = null;
			availableGames = null;
			scheduler.shutdown();
			notificationHandle.cancel(true);
			gameFullSub.remove();
			gameAdvertisementSub.remove();
			return null;
		}

		// cleanup
		scheduler.shutdown();
		notificationHandle.cancel(true);
		gameFullSub.remove();
		gameAdvertisementSub.remove();

		// At this point, we wish to notify the host that we wish to join their
		// game.
		if (joinGame()) {
			System.err.println("Error Joining Game.");
			currentGameMembers = null;
			availableGames = null;
			return null;
		}

		System.out.println("Joined Game!\n");

		ArrayList<User> tmp = new ArrayList<User>(currentGameMembers);
		// currentGameMembers = null;
		availableGames = null;
		return tmp;
	}