Add scope tracking in token router
Fix order of check for “{” and “}”