Updated pagination for better abstraction