conditional loop with next