fixed obvious thread safetey flaw (strtok -> strtok_r)