Ensure total pages calculation is correct