diff --git a/magic.sty b/magic.sty
index 2c6d8f42a15def4363b98aa425d6c3945af1518c..cbd3a726b6ac54cb324f328f79c872a17564dfeb 100644
--- a/magic.sty
+++ b/magic.sty
@@ -30,7 +30,7 @@
 \newcommand\setRange{%
   \iftoggle{distant}%
     {%
-      \ifcase\value{spelllevel}\relax%
+      \ifcase\value{spellCost}\relax%
       \renewcommand\spellRange{Error}%
       \or%
       \renewcommand\spellRange{Error}%
@@ -46,7 +46,7 @@
     }%
     {%
       \setcounter{track}{20}%
-      \Repeat{\arabic{spelllevel}}{\addtocounter{track}{-4}}%
+      \Repeat{\arabic{spellCost}}{\addtocounter{track}{-4}}%
       \ifnum\value{track}<1%
         \renewcommand\spellRange{touch}%
       \else%