Made the token detection a little smarter