fix bad token detection