move replace_text function to another thread
move append function to another thread
reduce duplicate codes
move function prepend words to another thread