solving token_auth referenced before assginment issue