cleaning up the index.php file & moving pagers to separate function