refactored channel into a function callback