Check for token type instead of handling an exception