Create Pagination.php

separate functions for improved performance and organization