token management in place
refactored code