switched to pthreads