added token print and fixed bug