Updated token generation function