Updated getToken functionality