added the new code for pagination