refactor method Connection::getStream()