function next_token works