can you cache the result from `views[nextPageIndex]` and make this `if` go on line line?