close analysis of doNext() loop