added token_generate function