pages idx out of bounds fix for paging