Fix the bug that will cause page out of range when updating the current
page together with the total pages.