fixed potential crash for next_token