Added parameter "pageCountVar" for specifying name of variable with number of pages