simplified the code in InputChannel