corrected logic for page_referenced function