add events and functions to handle pagination on main page