Adjusted the paginate function to only attempt a length check if per_page is valid...