diff --git a/src/Entity/EntityService.php b/src/Entity/EntityService.php
index <HASH>..<HASH> 100644
--- a/src/Entity/EntityService.php
+++ b/src/Entity/EntityService.php
@@ -94,11 +94,12 @@ abstract class EntityService
             );
         }
 
-        $entities = $this->getRepository()->getPaginatedEntities($options);
-        $options['pages'] = ceil($entities->count() / $options['elementsPerPage']);
         $options['page'] = $this->getPage($request);
         $options['elementsPerPage'] = $this->elementsPerPage;
 
+        $entities = $this->getRepository()->getPaginatedEntities($options);
+        $options['pages'] = ceil($entities->count() / $options['elementsPerPage']);
+
         return array(
             'entities' => $entities,
             'options' => $options
Fixed the order for the creation of options