Update pagination.php

Fix potential pagination issues