Fixing an exception when the page is out of range