Updated pagination function

Condensed the pagination file and function to a more compact format,
reducing overhead