Refactored text editing