@Override
	public JSONObject doCommand(JSONObject input) throws JSONException {

		int x1 = 0;
		int y1 = 0;

		int id = -1;
		int error = -1;
		boolean won = false;
		JSONArray command = null;

		try {
			id = input.getInt("ID");
			command = input.getJSONArray("COMMAND");
		} catch (JSONException e) {
			System.err.println("Malformed JSON");
			error = 3;
		}

		String commandName = null;
		commandName = (String) command.getString(0);

		if (commandName.equalsIgnoreCase("move")) {

			if (whoseTurn == id) {

				x1 = command.getInt(1);
				y1 = command.getInt(2);

				ArrayList<Integer> coordList = new ArrayList<Integer>();

				for (int i = 3; i < command.length(); i++) {
					coordList.add(command.getInt(i));
				}

				if (validMove(x1, y1, coordList)) {
					doMove(x1, y1, coordList);
					System.out.println("Move successful");
					error = 0;
					if (checkWin(id)) {
						System.out.println("Player " + id + " won");
						won = true;
						whoWon = id;
						gameRunning = false;
					}

				} else {
					error = 2;
				}

			} else {
				error = 1;
			}

		}

		JSONObject rWhat = new JSONObject();
		try {
			rWhat.put("ERROR", error);
			rWhat.put("WON", won);
		} catch (JSONException e) {
			e.printStackTrace();
			System.err.println("Error creating return object");
		}
		return rWhat;

	}