void (long pagesAmountInFile) { Page lastPageInDocument = documentOfPagesModel.getLastPage(); if (lastPageInDocument.isLastInFile() != (lastPageInDocument.getPageNumber() == pagesAmountInFile - 1)) { removeLastPageFromDocument(); pagesCash.removeIf(page -> lastPageInDocument.getPageNumber() == page.getPageNumber()); } }