Refactored selectText()