Solving problem 2 with channels