diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php
index cc53353f4db7a099c78142efd8223f0e58f10099..bbc80feb598212a65c96c051222b81e2a832baf8 100644
--- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php
+++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php
@@ -180,8 +180,9 @@ class Backend implements BackendInterface, SimilarInterface, RetrieveBatchInterf
         $this->injectSourceIdentifier($collection);
 
         if ($spellcheck) {
+            $spellcheckQuery = $params->get('spellcheck.q');
             $this->aggregateSpellcheck(
-                $collection->getSpellcheck(), end($params->get('spellcheck.q'))
+                $collection->getSpellcheck(), end($spellcheckQuery)
             );
         }