added better error handling in createFunc, pthread_create is failing for a small percentage of time