rearrange the api for text processing