Bug fix for pagination