Fixed undefined index 'lastPage'