why the double loop