Added functionality to deal with token expiration