used strtok instead of custom written tokenizer (stupid)
added error handling