public synchronized String flag(int x, int y) {
        String boardMessage;
        if (x < 0 || y < 0 || x >= size || y >= size
                || getCell(x, y).getState() != "untouched") {
            boardMessage = createBoard();
        } else {
            setCellState(x, y, "flagged");
            boardMessage = createBoard();
        }
        return boardMessage;
    }