fix createToken method: segmentation fault