public void click(int column, int row) {
        if (!selected) {
            if (pieces[column][row] != null && pieces[column][row].getColor() == activePlayer) {
                selected = true;
                selectedColumn = column;
                selectedRow = row;
                possibleMoves.addAll(pieces[column][row].getPossibleMoves(this, new BoardPosition(column, row)));
                //filter out moves that endanger the king
                filterMovesCausingCheck(possibleMoves, new BoardPosition(selectedColumn, selectedRow));
            }
        } else {
            if (selectedColumn == column && selectedRow == row) {
                selected = false;
                possibleMoves.clear();
            } else if (possibleMoves.contains(new BoardPosition(column, row))) {
                performMove(column, row);

            }
        }
    }