private void moveCurrentlySelectedPiece(ChessSpaceButton clickedButton)
    {
        assert pieceIsSelected;
        final int selectedRow = currentlySelectedButton.getRow();
        final int selectedColumn = currentlySelectedButton.getColumn();
        final int clickedRow = clickedButton.getRow();
        final int clickedColumn = clickedButton.getColumn();
        // have to translate board positions because the model and view have different layout
        final int modelOldRow = viewRowToModel(selectedRow);
        final int modelOldColumn = viewColumnToModel(selectedColumn);
        final int modelNewRow = viewRowToModel(clickedRow);
        final int modelNewColumn = viewColumnToModel(clickedColumn);

        view.moveChessPiece(selectedRow, selectedColumn, clickedRow, clickedColumn);
        if (modelBoard.canCastle(modelOldRow, modelOldColumn, modelNewRow, modelNewColumn)) {
            modelBoard.castle(modelOldRow, modelOldColumn, modelNewRow, modelNewColumn);
            if (modelNewColumn > modelOldColumn)
                view.moveChessPiece(clickedRow, 7, clickedRow, 5); // castle right
            else
                view.moveChessPiece(clickedRow, 0, clickedRow, 3); // castle left
        } else if (modelBoard.canEnPassant(modelOldRow, modelOldColumn, modelNewRow, modelNewColumn)) {
            modelBoard.enPassant(modelOldRow, modelOldColumn, modelNewRow, modelNewColumn);
            view.emptySpace(selectedRow, clickedColumn);
        } else {
            modelBoard.move(modelOldRow, modelOldColumn, modelNewRow, modelNewColumn);
        }

        if (modelBoard.canPromotePawn(modelNewRow, modelNewColumn)) {
            String choice = view.chooseChessPieceToReplacePawn(clickedRow, clickedColumn);
            ChessPiece replacement;
            switch (choice) {
            case "Knight":
                replacement = new Knight(modelNewRow, modelNewColumn, currentPlayerColor);
                break;
            case "Rook":
                replacement = new Rook(modelNewRow, modelNewColumn, currentPlayerColor);
                break;
            case "Bishop":
                replacement = new Bishop(modelNewRow, modelNewColumn, currentPlayerColor);
                break;
            case "Queen":
            default:
                replacement = new Queen(modelNewRow, modelNewColumn, currentPlayerColor);
                break;
            }
            modelBoard.addPiece(replacement);
        }
    }