Improve detecting the token when using selection