Fixed issue with pagination function returning array with a null element when passed an empty array