code fixes for pagination