refactor getToken