modularizing pagination