fix number of pages bug