moved delay method inside each loop