Smart token refresh