Not sure how the logic could be flawed since I didn't provide any SILVER PLATTER code.

I only provided what I think would be a better TYPE of solution.

I could / would write some Silver Platter code if the original poster requests it though.