token service refactoring