Paginate condition

This should guide you some what in the right direction: