added support for pagination