Fixes bug with an empty query result breaking the pagination.