optimize the code about paginator.php