Text input refactoring