Tube lemma generalization

So, here's the problem:

Let A and B be compact subspaces of X and Y, respectively. Let N be an open set in X x Y containing A x B. One needs to show that there exist open sets U in X and V in Y such that A x B $\displaystyle \subseteq$ U x V $\displaystyle \subseteq$ N.

Here's my try:

First of all, since N is open, it can be written as a union of basis elements in X x Y, i.e. let N = $\displaystyle \cup U_{i} \times V_{i}$.

Then we cover A x B with basis elements contained in N, so that $\displaystyle A \times B \subseteq \cup U_{i}' \times V_{i}'$ . Since A and B are compact, so is A x B, and for this cover, we have a finite subcover, so that $\displaystyle A \times B \subseteq \cup_{i=1}^n U_{i}' \times V_{i}'$.

Now we have the following relation:

$\displaystyle A \times B \subseteq \cup_{i=1}^n U_{i}' \times V_{i}' \subseteq \cup U_{i} \times V_{i} = N$.

Now, I'm not sure if this relation holds:

$\displaystyle \cup_{i=1}^n (U_{i}' \times V_{i}') \cap (\cup U_{i} \times V_{i}) \subseteq \cup_{i=1}^n (U_{i}' \cap (\cup U_{i})) \times \cup_{i=1}^n (V_{i}' \cap (\cup V_{i})) \subseteq N$. If it does, then $\displaystyle U = \cup_{i=1}^n (U_{i}' \cap (\cup U_{i}))$ and $\displaystyle V = \cup_{i=1}^n (V_{i}' \cap (\cup V_{i}))$ are the sets we were looking for.

If x = (a, b) is in $\displaystyle (\cup_{i=1}^n (U_{i}' \times V_{i}')) \cap (\cup U_{i} \times V_{i})$ then a is in Ui, b is in Vi, for some i, and a is in Ui' and b is in Vi'. So, a is in the intersection of Ui and Ui', for some i, and b is in the intersection of Vi and Vi', for some i, i.e. in their unions, so x is in $\displaystyle (\cup_{i=1}^n (U_{i}' \cap (\cup U_{i}))) \times (\cup_{i=1}^n (V_{i}' \cap (\cup V_{i})))$.

Does this work?

Edit: just edited this message, sorry for the math-typing inconvenience before.