changed tokenize function