I want to enclose my matrix by a box. I have followed the instructions in this link but couldnt get the borders correct. Here is how the frame looks like and the code.

\begin{frame}
\medskip\par\noindent
\begin{minipage}{0.4\linewidth}
\newcommand*{\WidestText}{
\begin{bmatrix}
1 & 2 & 3 \\[0.3em]\end{bmatrix}.*
\begin{bmatrix}
4 \\[0.3em]
2 \\[0.3em]
1 \\[0.3em]
\end{bmatrix}
=\text{ERROR}
}%
\tikzmark{left}
{\footnotesize
\[
\begin{bmatrix}
1 & 2 & 3 \\[0.3em]\end{bmatrix}.*
\begin{bmatrix}
4 \\[0.3em]
2 \\[0.3em]
1 \\[0.3em]
\end{bmatrix}
=\text{ERROR}
\]
}
{\footnotesize
\[\begin{bmatrix}
1 \\[0.3em]
2 \\[0.3em]
3 \\[0.3em]
\end{bmatrix}
.*
\begin{bmatrix}
4 \\[0.3em]
2 \\[0.3em]
1 \\[0.3em]
\end{bmatrix}
=
\begin{bmatrix}
4 \\[0.3em]
4 \\[0.3em]
3 \\[0.3em]
\end{bmatrix}
\]
}
\makebox[\widthof{\WidestText}][l]{ }\tikzmark{right}
\DrawBoxWide[thick, brown]
\end{minipage}
\end{frame}
