Fixed a case where pageAt could become negative