use tokenize instead of regex
helper functions for tokenize