I have a function that checks the existence and validity of a token and makes a new request to get a new token if the token does not exists or is expired. But the function a