refactoring token state.