Handle pagination correctly.