updated page number algorithmn