replace_text method updated