modifying code to partially support Bootstrap 3 pagination