Fixed variable scope.

Fixed output in pagination.