updated with streaming write