extending a vector field defined on a closed submanifold

Let $M$ be a differentiable (smooth) manifold, and $S$ a closed submanifold. Let $X$ be a vector field on $S$. Prove that $X$ is the restriction of a vector field $Y$ defined on $M$. I tried this way but i'm not completely sure: i choose a covering (maybe finite if with closed we intend compact) of $S$ with $U_j$ open in $M$. Then i consider a partition of unity $w_i$ subordinate to this covering (can I?). Then i have $Z=\sum_i w_iX$ is a vector field extending $X$ in the open covering. Then i use a result that states that i can extend on the whole $M$ a vector field defined in an open set of $M$. Is this correct?


Take a submanifold chart $x:U\rightarrow x(U) \subseteq \mathbb R^n$ such that $x(S\cap U) = \{x^{k+1}=\dots x^n=0\}$ (edit: and $x(U)$ is a ball)).

Then you can define a vector field $Z$ on $x(U)$, by $$ Z(x_1,\dots,x_n):=x_* (X(x^{-1}(x_1,\dots,x_k,0,\dots,0))) $$

Transport back to $M$ and get $x^{-1}_* Z$ on $U$ and then use a partition of unity argument!