refactor on NetworkStream