Uniqueness of Jordan normal form via the Structure Theorem

I have proved the existence of the Jordan normal form of a matrix with coefficients over a field $K$ via the Structure Theorem for modules over PIDs.

I'm now trying to prove the uniqueness part.

If I have $A=CJC^{-1}$ with $J$ in Jordan normal form, I have that $(K^n, \cdot_J)$ is a $K[x]$ module via $p(x) \cdot_J v = p(J) v$

$(J^n, \cdot_A)$ is also a $K[x]$ module via $p(x) \cdot_A v = p(A) v$, and it's easy to see that both $K[x]$-modules are isomorphic via $\phi(v)=C^{-1} v$

So $(K^n,\cdot_A) \approx (K^n, \cdot_J)$. It now suffices to see that $(K^n, \cdot_J) \approx K[X]/<(x-\lambda_1)^{g_1}> \oplus ... \oplus\ K[X]/<(x-\lambda_m)^{g_m}>$, where $(\lambda_i,g_i)$ are the eigenvalues and the sizes of the Jordan blocks, respectively.

That's enough because if I see this, I can use the uniqueness of the structure theorem to conclude that the decomposition I made using the theorem is equivalent to $CJC^{-1}$.

$$K^n \ni (a_{10},...,a_{1g_{1}-1},...,a_{m0},...,a_{mg_{m}-1}) \mapsto (..., \sum_{j=0}^{g_i-1} a_{ij} (\overline{x-\lambda_i)}^j,...) \in E$$
where $E=K[X]/<(x-\lambda_1)^{g_1}> \oplus ... \oplus\ K[X]/<(x-\lambda_m)^{g_m}>$$It's easy to see that it's linear and an epimorphism. To see that it's a monomorphism, suppose the image of certain$a \in K^n$we have that$\forall\ i \sum_{j=0}^{g_i-1} a_{ij} (\overline{x-\lambda_i)}^j,...) = \bar{0}$, then$\sum_{j=0}^{g_i-1} a_{ij} (x-\lambda_i)^j$is a multiple of$(x-\lambda_i)^{g_i}$, but as the degree of the first polynomial is strictly lower than the one of the second, it must be zero, so$a_{ij}=0 \forall\ j$. As this happens$\forall\ i, a=0\$.