speed up process_text a bit

This pr speeds up a bit the ``process_text`` function.
Thanks