nextterm is now an array index

int nextterm;