Your sentence is grammatically correct. I would characterize it stylistically as an example of what I call "stutter-style", which is not necessarily bad. In this sort of style you break up the main idea of the sentence by inserting subordinate ideas along the way rather than putting them in their usual positions.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.