Refactored building of page number.