resturcture the code and add buffer for a few channel
restructure the code