Factor out tokenization