fixed bugs when retrieve tokens in controllers