Fix conditional pagination