use channel instead for loop