Comment: function to calculate total pages