Fixed bug where an infinity loop started.
-Code was attempting to find the next iteration when in fact there was
none.