bug fixes for pagination