cleaned up the way the selectedText is accessed