added get_random_pid/1 error handling