fix next() function for python2.5 compatibility