Refactors nextPageMatch (nits)
Merge pull request #4210 from yurydelendik/issue4131

Refactors nextPageMatch (nits)