Fixes bugzilla FF bug 960409

Fixes FF bug 960409 by changing nextPageMatch from a recursive function to an iterative function.