change strtok usage to strtok_r