clean up
template for parallelizing writer and reader