Fix bug for pagination