refactored updateToken, corrected token retrieval