added pthreads to capture to file