minor revision to tokenize function