public void toggleSquare(int x, int y) {

		//first check we are are allowed to make a move 
		if (!checkValidMove(x, y)) return;

		Square square = board.getSquare(x, y);

		if (square.isRevealed()) {
			//do nothing
			return;
		}
		if (square.isFlagged()) 
			minesUnflagged++;
		
		//toggle flag and notify listener
		switch(square.toggleState()) {
		case flagged:
			listener.squareFlagged(x, y);
			minesUnflagged--;
			break;
		case unmarked:
			listener.squareUnmarked(x, y);
			break;
		case questioned:
			listener.squareQuestioned(x, y);
			break;
		default:
			break;
		}
		
		listener.totalFlagsChanged(minesUnflagged);
	}