created separate thread for writer to speed up processing