added check for non eof errors, channels close defer