custom strtok_r implementation