Would you mind to add a comment what this code is doing, and why you have to parse twice? That would help a lot. Thanks.