added function to get next token and store its value