Handle invalid user-entered page number

If user enters a page number which exceeds lastPage, then use lastPage.