The wording on this sentence is a bit weird. There's two "when"s.