refactor tokenize