improved tokenization (still not perfect)