Adding the code for pagination