check for buffer or stream