We give sufficient conditions for hypoellipticity of a second order operator with real-valued infinitely differentiable coefficients whose principal part is the product of a real-valued infinitely differentiable function $\phi (x)$ and the sum of squares of first order operators $X_{1}, \ldots , X_{r}$ . These conditions are related to the way in which $\phi(x)$ changes its sign, and the rank of the Lie algebra generated by $\phi X_{1},\ldots , \phi X_{r}$ and $X_{0}$ where $X_{0}$ is the first order term of the operator. Our result is an extension of that of [4], and it includes some cases not treated in [1], [5] and [8].