if you use ``izip`` then you can avoid the nested while loop