fix off by one while checking for the maximum number of tokens