refactor allocate channel