Refactored to use displayPaging() function for paging