added support for pagination in server.js