implemented token handling