Use strtok_r for thread-safety