add more comments to describe what this while loop do.