This is not the loop I woudl have thought.  Don't you need the double logic inside the loop?