Fix bug in token regeneration