better error handling for pthreads