rand() has a lock on it, use rand_r() with provided seed instead