added generate_token function