handle invalid tokens without exploding