added conditional logic if no pages on pages index