Funny, I actually did this reaction in the lab quite recently.
You're basically half way there. There are a number of plausible pathways differing in the order of steps. Let's go with what you have so far (a Knoevenagel condensation).
Think about that intermediate and remember that intramolecular reactions are generally faster than intermolecular reactions...