@Override
	public void run() {
		try {
			while (true) {
				synchronized (this) {
					this.isDone = true;
					this.action = null;
					while (this.action == null) {
						this.println("waiting for an action");
						this.wait();
					}
					this.isDone = false;
					this.send(this.action, cloudChannel);
					// output messages based on choice of action.
					this.println("Cloud notified");
					switch (this.action.getCommand()) {
					case authenticate:
						this.println("Auth status received");
						this.isAuthenticated = (boolean) cloudChannel.getResponse(this);
						break;
					default:
						this.println(this.action.getCommand() + " completed");
						int balance = (int) cloudChannel.getResponse(this);
						this.println("Your balance is now: " + balance);
						break;
					}
				}
				synchronized (atmTerminal) {
					atmTerminal.notify();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}