new function to get pages until the previous chapter