implement swap_text operation