Added detection of total page number.