Can you please refactor the content of the if starting at

```
var currentId = PDFView.page, lastPage = PDFView.pdfDocument.numPages;
```

 in it's own function?