refactor to use channels as callbacks not not functions